package cn.xy.ymcc.feign;

import cn.xy.ymcc.doc.CourseDoc;
import cn.xy.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class CourseSearchFeignClientFallBackFactory implements FallbackFactory<CourseSearchFeignClient> {
    @Override
    public CourseSearchFeignClient create(Throwable throwable) {
        return new CourseSearchFeignClient() {
            @Override
            public JSONResult saveCourse(CourseDoc doc) {
                throwable.printStackTrace();
                return JSONResult.error("搜索服务不可达");


            }

            @Override
            public JSONResult offLineCourse(Long courseId) {
                return JSONResult.error("下架失败");
            }
        };
    }
}
